Executive summary

Case

Procedure
xyz

Results
xyz

Limitations

Recommendations

Technical documentation

Table of contents
1. Data exploration & pre-processing
1.1 Placeholder
2. Comparison of product portfolio
3. Analysis on customer segments (B2C, B2B)
4. Association rules mining
5. Selection of rules

1. Exploration and preparation of data

## transactions in sparse format with
##  9835 transactions (rows) and
##  125 items (columns)
## transactions as itemMatrix in sparse format with
##  9835 rows (elements/itemsets/transactions) and
##  125 columns (items) and a density of 0.03506172 
## 
## most frequent items:
##                     iMac                HP Laptop CYBERPOWER Gamer Desktop 
##                     2519                     1909                     1809 
##            Apple Earpods        Apple MacBook Air                  (Other) 
##                     1715                     1530                    33622 
## 
## element (itemset/transaction) length distribution:
## sizes
##    0    1    2    3    4    5    6    7    8    9   10   11   12   13   14 
##    2 2163 1647 1294 1021  856  646  540  439  353  247  171  119   77   72 
##   15   16   17   18   19   20   21   22   23   25   26   27   29   30 
##   56   41   26   20   10   10   10    5    3    1    1    3    1    1 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.000   2.000   3.000   4.383   6.000  30.000 
## 
## includes extended item information - examples:
##                             labels
## 1 1TB Portable External Hard Drive
## 2 2TB Portable External Hard Drive
## 3                   3-Button Mouse
## [1] 4.382715

transactions_raw@itemInfo$il_new <- df_names$il_new
transactions_raw@itemInfo$brand <- df_names$brand
transactions_raw@itemInfo$category <- df_names$category

trans_il_new <- arules::aggregate(transactions_raw, by = "il_new")
df_trans_il_new <- data.frame(as(trans_il_new, "matrix"))

trans_brand <- arules::aggregate(transactions_raw, by = "brand")
df_trans_brand <- data.frame(as(trans_brand, "matrix"))

trans_category <- arules::aggregate(transactions_raw, by = "category")
df_trans_cat <- data.frame(as(trans_category, "matrix"))

2. Comparison of product portfolio

’Accessories contain ’Computer Cords’, ’Computer Stands’, ’External Hardrives’, ’Keyboard’, ’Mouse’, ’Mouse and Keyboard’ ’’Speakers contain ’Computer Headphones’, ‘Active Headphones’

3. Analysis on customer segments (B2C, B2B)

# Extract 'big products' (PC and Laptop)
bigprod <- c("Acer Aspire", "Alienware Laptop", "Apple MacBook Air",
             "Apple MacBook Pro", "ASUS Chromebook", "Dell Laptop",
             "Eluktronics Pro Gaming Laptop", "HP Laptop", "HP Notebook Touchscreen Laptop",
             "LG Touchscreen Laptop", "Acer Desktop", "ASUS Desktop", "CYBERPOWER Gamer Desktop",
             "Dell 2 Desktop", "Dell Desktop", "HP Desktop", "iMac",
             "Intel Desktop", "Lenovo Desktop Computer")
colnos_big <- c()
# Finding transactions for PC and/or laptop
for (i in bigprod) {
  colnos_big <- c(colnos_big, which(colnames(df_trans_bin) == i))
}

colnos_big
##  [1]  6 10 14 15 21 39 46 64 82  7 22 35 36 37 63 70 71 80
valueprod <- rowSums(df_trans_bin[, c(colnos_big)])
df_comparison <- df_trans_bin
df_comparison$valueprods <- valueprod

others <- rowSums(df_trans_bin[, -c(colnos_big)])
df_comparison$others <- others



# Extract 'printers'
printers <- c("Brother Printer", "Canon Office Printer", "DYMO Label Manker",
              "Epson Printer", "HP Wireless Printer")

colnos_print <- c()

for (i in printers) {
  colnos_print <- c(colnos_print, which(colnames(df_trans_bin) == i))
}

colnos_print
## [1] 28 32 43 48 69
Printers <- rowSums(df_trans_bin[, c(colnos_print)])
df_comparison$Printers <- Printers

# Extract 'Monitors'
monitors <- c("Acer Monitor", "AOC Monitor", "ASUS 2 Monitor",
              "ASUS Monitor", "Dell Monitor", "HP Monitor",
              "LG Monitor", "Samsung Monitor", "Sceptre Monitor",
              "ViewSonic Monitor"
              )

colnons_monit <- c()

for (i in monitors) {
 colnons_monit <- c(colnons_monit, which(colnames(df_trans_bin) == i))
}

colnons_monit
##  [1]   8  11  20  23  40  65  81 114 115 122
monitors <- rowSums(df_trans_bin[, c(colnons_monit)])
df_comparison$monitors <- monitors


Trsize <- c()

for (i in 1:nrow(df_trans_bin)) {
 Trsize <- c(Trsize, sum(df_comparison[i,-c(126:128)]))
}

df_comparison$tsize <- Trsize

# found zero rows, zero items bought is not really a transaction

df_comparison <- df_comparison[-c(which(df_comparison$tsize == 0)),]

# Creaing df for cluster analysis
clusterdata_big <- c(df_comparison$valueprods, df_comparison$tsize)
clusterdata_others <- c(df_comparison$others, df_comparison$tsize)
clusterdata_bigothers <- c(df_comparison$valueprods, df_comparison$others)
clusterdata_print <- c(df_comparison$Printers, df_comparison$tsize)
clusterdata_monit <- c(df_comparison$monitors, df_comparison$tsize)

# Clustering analysis
trans_kmeans_big <- kmeans(clusterdata_big, 3)
trans_kmeans_others <- kmeans(clusterdata_others, 3)
trans_kmeans_bigothers <- kmeans(clusterdata_bigothers, 3)
trans_kmeans_print <- kmeans(clusterdata_print, 2)
trans_kmeans_monit <- kmeans(clusterdata_monit, 2)

# Visualization 
plot(df_comparison$Printers)

plot(df_comparison$monitors)

plot(x = df_comparison$valueprods, y = df_comparison$tsize, pch = trans_kmeans_big$cluster) +
points(trans_kmeans_big$centers, pch = 8, cex =3)

## integer(0)
plot(x = df_comparison$others, y = df_comparison$tsize, pch = trans_kmeans_others$cluster) + points(trans_kmeans_others$centers, pch = 8, cex =3)

## integer(0)
plot(x = df_comparison$valueprods, y = df_comparison$others, pch = trans_kmeans_bigothers$cluster) + points(trans_kmeans_bigothers$centers, pch = 8, cex =3)

## integer(0)
plot(x = df_comparison$Printers, y = df_comparison$tsize, pch = trans_kmeans_print$cluster) + points(trans_kmeans_bigothers$centers, pch = 8, cex =3)

## integer(0)
plot(x = df_comparison$monitors, y = df_comparison$tsize, pch = trans_kmeans_monit$cluster) + points(trans_kmeans_monit$centers, pch = 8, cex =3)

## integer(0)
bigdeals <- which(df_comparison$tsize >= 10)

View(bigdeals)

Bigdeals.df <- df_comparison[c(bigdeals),]

View(Bigdeals.df)

ggplot(data = Bigdeals.df, aes(x = Printers, y= tsize)) + geom_point()

ggplot(data = Bigdeals.df, aes(x = monitors, y= tsize)) + geom_point()

twocpus <- which(df_comparison$valueprods >= 2)
twoprints <- which(df_comparison$Printers >= 2)
twomons <- which(df_comparison$monitors >= 2)
tensize <- which(df_comparison$tsize >= 10)                                                         

b2b.sales <- df_comparison[c(twocpus, twomons, twoprints, tensize), ]

View(b2b.sales)

4. Association rules mining

##Out of the box
#rules cover 10% of the transactions(supp = .1) and are 80% correct (conf = .8)
rules <- apriori(transactions_raw, parameter = list(supp = 0.001, conf = 0.95, minlen = 2, maxlen = 10)) #first rules using supp = 0.001 and
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##        0.95    0.1    1 none FALSE            TRUE       5   0.001      2
##  maxlen target   ext
##      10  rules FALSE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 9 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[125 item(s), 9835 transaction(s)] done [0.00s].
## sorting and recoding items ... [125 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3 4 5 6 done [0.02s].
## writing ... [43 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
#0.0009 0.95 --> 98 rules
inspect(rules)
##      lhs                                                   rhs                           support confidence     lift count
## [1]  {Dell KM117 Wireless Keyboard & Mouse,                                                                               
##       iPhone Charger Cable}                             => {Apple MacBook Air}       0.002033554   0.952381 6.122004    20
## [2]  {Brother Printer,                                                                                                    
##       Halter Acrylic Monitor Stand}                     => {iMac}                    0.001118454   1.000000 3.904327    11
## [3]  {ASUS Monitor,                                                                                                       
##       Mackie CR Speakers,                                                                                                 
##       ViewSonic Monitor}                                => {iMac}                    0.001016777   1.000000 3.904327    10
## [4]  {Apple Magic Keyboard,                                                                                               
##       Rii LED Gaming Keyboard & Mouse Combo,                                                                              
##       ViewSonic Monitor}                                => {iMac}                    0.001728521   1.000000 3.904327    17
## [5]  {ASUS Monitor,                                                                                                       
##       Koss Home Headphones,                                                                                               
##       Microsoft Office Home and Student 2016}           => {iMac}                    0.001016777   1.000000 3.904327    10
## [6]  {Acer Aspire,                                                                                                        
##       Koss Home Headphones,                                                                                               
##       ViewSonic Monitor}                                => {HP Laptop}               0.001220132   1.000000 5.151912    12
## [7]  {Dell Desktop,                                                                                                       
##       Koss Home Headphones,                                                                                               
##       ViewSonic Monitor}                                => {HP Laptop}               0.001118454   1.000000 5.151912    11
## [8]  {ASUS 2 Monitor,                                                                                                     
##       Dell Desktop,                                                                                                       
##       Logitech Keyboard}                                => {iMac}                    0.001016777   1.000000 3.904327    10
## [9]  {Alienware Laptop,                                                                                                   
##       ASUS Desktop,                                                                                                       
##       Lenovo Desktop Computer}                          => {iMac}                    0.001016777   1.000000 3.904327    10
## [10] {Brother Printer,                                                                                                    
##       Dell Desktop,                                                                                                       
##       Epson Printer}                                    => {iMac}                    0.001118454   1.000000 3.904327    11
## [11] {Apple Magic Keyboard,                                                                                               
##       Brother Printer,                                                                                                    
##       ViewSonic Monitor}                                => {iMac}                    0.001016777   1.000000 3.904327    10
## [12] {ASUS Desktop,                                                                                                       
##       Dell Desktop,                                                                                                       
##       Microsoft Office Home and Student 2016}           => {iMac}                    0.001016777   1.000000 3.904327    10
## [13] {Intel Desktop,                                                                                                      
##       iPad Pro,                                                                                                           
##       Microsoft Office Home and Student 2016}           => {iMac}                    0.001118454   1.000000 3.904327    11
## [14] {Acer Aspire,                                                                                                        
##       ASUS 2 Monitor,                                                                                                     
##       Intel Desktop}                                    => {HP Laptop}               0.001016777   1.000000 5.151912    10
## [15] {ASUS Monitor,                                                                                                       
##       Intel Desktop,                                                                                                      
##       ViewSonic Monitor}                                => {Lenovo Desktop Computer} 0.001118454   1.000000 6.754808    11
## [16] {ASUS 2 Monitor,                                                                                                     
##       Computer Game,                                                                                                      
##       Dell Desktop}                                     => {HP Laptop}               0.001016777   1.000000 5.151912    10
## [17] {Dell Desktop,                                                                                                       
##       iMac,                                                                                                               
##       Lenovo Desktop Computer,                                                                                            
##       Mackie CR Speakers}                               => {ViewSonic Monitor}       0.001118454   1.000000 9.064516    11
## [18] {Acer Aspire,                                                                                                        
##       Apple MacBook Pro,                                                                                                  
##       HP Black & Tri-color Ink,                                                                                           
##       HP Laptop}                                        => {iMac}                    0.001016777   1.000000 3.904327    10
## [19] {Dell Desktop,                                                                                                       
##       iMac,                                                                                                               
##       Lenovo Desktop Computer,                                                                                            
##       Logitech MK270 Wireless Keyboard and Mouse Combo} => {HP Laptop}               0.001118454   1.000000 5.151912    11
## [20] {Acer Desktop,                                                                                                       
##       Dell Desktop,                                                                                                       
##       HDMI Cable 6ft,                                                                                                     
##       iMac}                                             => {HP Laptop}               0.001321810   1.000000 5.151912    13
## [21] {Dell Desktop,                                                                                                       
##       Etekcity Power Extension Cord Cable,                                                                                
##       Lenovo Desktop Computer,                                                                                            
##       ViewSonic Monitor}                                => {iMac}                    0.001220132   1.000000 3.904327    12
## [22] {Etekcity Power Extension Cord Cable,                                                                                
##       HP Laptop,                                                                                                          
##       Lenovo Desktop Computer,                                                                                            
##       ViewSonic Monitor}                                => {iMac}                    0.001626843   1.000000 3.904327    16
## [23] {Apple Magic Keyboard,                                                                                               
##       ASUS Desktop,                                                                                                       
##       Dell Desktop,                                                                                                       
##       Lenovo Desktop Computer}                          => {iMac}                    0.001016777   1.000000 3.904327    10
## [24] {ASUS Monitor,                                                                                                       
##       iMac,                                                                                                               
##       Intel Desktop,                                                                                                      
##       ViewSonic Monitor}                                => {Lenovo Desktop Computer} 0.001016777   1.000000 6.754808    10
## [25] {AOC Monitor,                                                                                                        
##       ASUS Monitor,                                                                                                       
##       HP Laptop,                                                                                                          
##       ViewSonic Monitor}                                => {iMac}                    0.001016777   1.000000 3.904327    10
## [26] {AOC Monitor,                                                                                                        
##       Dell Desktop,                                                                                                       
##       Lenovo Desktop Computer,                                                                                            
##       ViewSonic Monitor}                                => {iMac}                    0.001118454   1.000000 3.904327    11
## [27] {Acer Aspire,                                                                                                        
##       Computer Game,                                                                                                      
##       Dell Desktop,                                                                                                       
##       ViewSonic Monitor}                                => {HP Laptop}               0.001118454   1.000000 5.151912    11
## [28] {Epson Printer,                                                                                                      
##       HP Monitor,                                                                                                         
##       Lenovo Desktop Computer,                                                                                            
##       ViewSonic Monitor}                                => {iMac}                    0.001016777   1.000000 3.904327    10
## [29] {Apple Magic Keyboard,                                                                                               
##       ASUS Monitor,                                                                                                       
##       HP Laptop,                                                                                                          
##       LG Monitor}                                       => {iMac}                    0.001016777   1.000000 3.904327    10
## [30] {Apple Magic Keyboard,                                                                                               
##       ASUS Monitor,                                                                                                       
##       Dell Desktop,                                                                                                       
##       Microsoft Office Home and Student 2016}           => {iMac}                    0.001016777   1.000000 3.904327    10
## [31] {Apple Magic Keyboard,                                                                                               
##       ASUS Monitor,                                                                                                       
##       HP Laptop,                                                                                                          
##       Microsoft Office Home and Student 2016}           => {iMac}                    0.001220132   1.000000 3.904327    12
## [32] {Apple Magic Keyboard,                                                                                               
##       ASUS Monitor,                                                                                                       
##       Dell Desktop,                                                                                                       
##       HP Monitor}                                       => {HP Laptop}               0.001118454   1.000000 5.151912    11
## [33] {Acer Desktop,                                                                                                       
##       Apple Magic Keyboard,                                                                                               
##       ASUS Monitor,                                                                                                       
##       ViewSonic Monitor}                                => {iMac}                    0.001016777   1.000000 3.904327    10
## [34] {Apple Earpods,                                                                                                      
##       Backlit LED Gaming Keyboard,                                                                                        
##       CYBERPOWER Gamer Desktop,                                                                                           
##       iMac}                                             => {HP Laptop}               0.001016777   1.000000 5.151912    10
## [35] {Acer Desktop,                                                                                                       
##       Apple Magic Keyboard,                                                                                               
##       Dell Desktop,                                                                                                       
##       HP Monitor}                                       => {HP Laptop}               0.001016777   1.000000 5.151912    10
## [36] {3-Button Mouse,                                                                                                     
##       Acer Aspire,                                                                                                        
##       Apple Magic Keyboard,                                                                                               
##       CYBERPOWER Gamer Desktop}                         => {iMac}                    0.001016777   1.000000 3.904327    10
## [37] {Acer Aspire,                                                                                                        
##       Apple Magic Keyboard,                                                                                               
##       Dell Desktop,                                                                                                       
##       ViewSonic Monitor}                                => {HP Laptop}               0.001423488   1.000000 5.151912    14
## [38] {3-Button Mouse,                                                                                                     
##       Acer Aspire,                                                                                                        
##       Dell Desktop,                                                                                                       
##       ViewSonic Monitor}                                => {HP Laptop}               0.001016777   1.000000 5.151912    10
## [39] {CYBERPOWER Gamer Desktop,                                                                                           
##       Dell Desktop,                                                                                                       
##       Samsung Monitor,                                                                                                    
##       ViewSonic Monitor}                                => {iMac}                    0.001016777   1.000000 3.904327    10
## [40] {Dell Desktop,                                                                                                       
##       HP Laptop,                                                                                                          
##       iMac,                                                                                                               
##       Lenovo Desktop Computer,                                                                                            
##       Mackie CR Speakers}                               => {ViewSonic Monitor}       0.001016777   1.000000 9.064516    10
## [41] {Dell Desktop,                                                                                                       
##       Etekcity Power Extension Cord Cable,                                                                                
##       HP Laptop,                                                                                                          
##       Lenovo Desktop Computer,                                                                                            
##       ViewSonic Monitor}                                => {iMac}                    0.001118454   1.000000 3.904327    11
## [42] {Acer Desktop,                                                                                                       
##       HP Laptop,                                                                                                          
##       HP Monitor,                                                                                                         
##       Lenovo Desktop Computer,                                                                                            
##       ViewSonic Monitor}                                => {iMac}                    0.001118454   1.000000 3.904327    11
## [43] {Acer Aspire,                                                                                                        
##       Apple Magic Keyboard,                                                                                               
##       Dell Desktop,                                                                                                       
##       iMac,                                                                                                               
##       ViewSonic Monitor}                                => {HP Laptop}               0.001016777   1.000000 5.151912    10
#### Functions for redundant and sort ####
# Check, exclude, sort, and select rules
func_redundant <- function (trans_data){
  sum(is.redundant(trans_data))
  rules_red <- trans_data[which(is.redundant(trans_data))]
  n_rules_red <- c(which(is.redundant(trans_data)))
  inspect(rules_red)
  
  # Exclude redundant rules
  rules_unique <<- trans_data[-c(n_rules_red)]
} # Inuts: trans_data = file with rules
# Sort rules in terms of support, confidence, lift
func_sort <- function (trans_data, by){
  rules_sorted <<- sort(trans_data, by = by, decreasing = TRUE)
  inspect(rules_sorted)
}  # Inuts: trans_data = file with rules; by = "metric" (e.g.: "support", "confidence", "count")

#### Analysis ####
# Check for redundant rules and exlude them
func_redundant(rules)
##     lhs                                      rhs                           support confidence     lift count
## [1] {ASUS Monitor,                                                                                          
##      iMac,                                                                                                  
##      Intel Desktop,                                                                                         
##      ViewSonic Monitor}                   => {Lenovo Desktop Computer} 0.001016777          1 6.754808    10
## [2] {Dell Desktop,                                                                                          
##      HP Laptop,                                                                                             
##      iMac,                                                                                                  
##      Lenovo Desktop Computer,                                                                               
##      Mackie CR Speakers}                  => {ViewSonic Monitor}       0.001016777          1 9.064516    10
## [3] {Dell Desktop,                                                                                          
##      Etekcity Power Extension Cord Cable,                                                                   
##      HP Laptop,                                                                                             
##      Lenovo Desktop Computer,                                                                               
##      ViewSonic Monitor}                   => {iMac}                    0.001118454          1 3.904327    11
## [4] {Acer Aspire,                                                                                           
##      Apple Magic Keyboard,                                                                                  
##      Dell Desktop,                                                                                          
##      iMac,                                                                                                  
##      ViewSonic Monitor}                   => {HP Laptop}               0.001016777          1 5.151912    10
# Sort rules in terms of support, confidence, lift
func_sort(rules_unique, "lift")
##      lhs                                                   rhs                           support confidence     lift count
## [1]  {Dell Desktop,                                                                                                       
##       iMac,                                                                                                               
##       Lenovo Desktop Computer,                                                                                            
##       Mackie CR Speakers}                               => {ViewSonic Monitor}       0.001118454   1.000000 9.064516    11
## [2]  {ASUS Monitor,                                                                                                       
##       Intel Desktop,                                                                                                      
##       ViewSonic Monitor}                                => {Lenovo Desktop Computer} 0.001118454   1.000000 6.754808    11
## [3]  {Dell KM117 Wireless Keyboard & Mouse,                                                                               
##       iPhone Charger Cable}                             => {Apple MacBook Air}       0.002033554   0.952381 6.122004    20
## [4]  {Acer Aspire,                                                                                                        
##       Koss Home Headphones,                                                                                               
##       ViewSonic Monitor}                                => {HP Laptop}               0.001220132   1.000000 5.151912    12
## [5]  {Dell Desktop,                                                                                                       
##       Koss Home Headphones,                                                                                               
##       ViewSonic Monitor}                                => {HP Laptop}               0.001118454   1.000000 5.151912    11
## [6]  {Acer Aspire,                                                                                                        
##       ASUS 2 Monitor,                                                                                                     
##       Intel Desktop}                                    => {HP Laptop}               0.001016777   1.000000 5.151912    10
## [7]  {ASUS 2 Monitor,                                                                                                     
##       Computer Game,                                                                                                      
##       Dell Desktop}                                     => {HP Laptop}               0.001016777   1.000000 5.151912    10
## [8]  {Dell Desktop,                                                                                                       
##       iMac,                                                                                                               
##       Lenovo Desktop Computer,                                                                                            
##       Logitech MK270 Wireless Keyboard and Mouse Combo} => {HP Laptop}               0.001118454   1.000000 5.151912    11
## [9]  {Acer Desktop,                                                                                                       
##       Dell Desktop,                                                                                                       
##       HDMI Cable 6ft,                                                                                                     
##       iMac}                                             => {HP Laptop}               0.001321810   1.000000 5.151912    13
## [10] {Acer Aspire,                                                                                                        
##       Computer Game,                                                                                                      
##       Dell Desktop,                                                                                                       
##       ViewSonic Monitor}                                => {HP Laptop}               0.001118454   1.000000 5.151912    11
## [11] {Apple Magic Keyboard,                                                                                               
##       ASUS Monitor,                                                                                                       
##       Dell Desktop,                                                                                                       
##       HP Monitor}                                       => {HP Laptop}               0.001118454   1.000000 5.151912    11
## [12] {Apple Earpods,                                                                                                      
##       Backlit LED Gaming Keyboard,                                                                                        
##       CYBERPOWER Gamer Desktop,                                                                                           
##       iMac}                                             => {HP Laptop}               0.001016777   1.000000 5.151912    10
## [13] {Acer Desktop,                                                                                                       
##       Apple Magic Keyboard,                                                                                               
##       Dell Desktop,                                                                                                       
##       HP Monitor}                                       => {HP Laptop}               0.001016777   1.000000 5.151912    10
## [14] {Acer Aspire,                                                                                                        
##       Apple Magic Keyboard,                                                                                               
##       Dell Desktop,                                                                                                       
##       ViewSonic Monitor}                                => {HP Laptop}               0.001423488   1.000000 5.151912    14
## [15] {3-Button Mouse,                                                                                                     
##       Acer Aspire,                                                                                                        
##       Dell Desktop,                                                                                                       
##       ViewSonic Monitor}                                => {HP Laptop}               0.001016777   1.000000 5.151912    10
## [16] {Brother Printer,                                                                                                    
##       Halter Acrylic Monitor Stand}                     => {iMac}                    0.001118454   1.000000 3.904327    11
## [17] {ASUS Monitor,                                                                                                       
##       Mackie CR Speakers,                                                                                                 
##       ViewSonic Monitor}                                => {iMac}                    0.001016777   1.000000 3.904327    10
## [18] {Apple Magic Keyboard,                                                                                               
##       Rii LED Gaming Keyboard & Mouse Combo,                                                                              
##       ViewSonic Monitor}                                => {iMac}                    0.001728521   1.000000 3.904327    17
## [19] {ASUS Monitor,                                                                                                       
##       Koss Home Headphones,                                                                                               
##       Microsoft Office Home and Student 2016}           => {iMac}                    0.001016777   1.000000 3.904327    10
## [20] {ASUS 2 Monitor,                                                                                                     
##       Dell Desktop,                                                                                                       
##       Logitech Keyboard}                                => {iMac}                    0.001016777   1.000000 3.904327    10
## [21] {Alienware Laptop,                                                                                                   
##       ASUS Desktop,                                                                                                       
##       Lenovo Desktop Computer}                          => {iMac}                    0.001016777   1.000000 3.904327    10
## [22] {Brother Printer,                                                                                                    
##       Dell Desktop,                                                                                                       
##       Epson Printer}                                    => {iMac}                    0.001118454   1.000000 3.904327    11
## [23] {Apple Magic Keyboard,                                                                                               
##       Brother Printer,                                                                                                    
##       ViewSonic Monitor}                                => {iMac}                    0.001016777   1.000000 3.904327    10
## [24] {ASUS Desktop,                                                                                                       
##       Dell Desktop,                                                                                                       
##       Microsoft Office Home and Student 2016}           => {iMac}                    0.001016777   1.000000 3.904327    10
## [25] {Intel Desktop,                                                                                                      
##       iPad Pro,                                                                                                           
##       Microsoft Office Home and Student 2016}           => {iMac}                    0.001118454   1.000000 3.904327    11
## [26] {Acer Aspire,                                                                                                        
##       Apple MacBook Pro,                                                                                                  
##       HP Black & Tri-color Ink,                                                                                           
##       HP Laptop}                                        => {iMac}                    0.001016777   1.000000 3.904327    10
## [27] {Dell Desktop,                                                                                                       
##       Etekcity Power Extension Cord Cable,                                                                                
##       Lenovo Desktop Computer,                                                                                            
##       ViewSonic Monitor}                                => {iMac}                    0.001220132   1.000000 3.904327    12
## [28] {Etekcity Power Extension Cord Cable,                                                                                
##       HP Laptop,                                                                                                          
##       Lenovo Desktop Computer,                                                                                            
##       ViewSonic Monitor}                                => {iMac}                    0.001626843   1.000000 3.904327    16
## [29] {Apple Magic Keyboard,                                                                                               
##       ASUS Desktop,                                                                                                       
##       Dell Desktop,                                                                                                       
##       Lenovo Desktop Computer}                          => {iMac}                    0.001016777   1.000000 3.904327    10
## [30] {AOC Monitor,                                                                                                        
##       ASUS Monitor,                                                                                                       
##       HP Laptop,                                                                                                          
##       ViewSonic Monitor}                                => {iMac}                    0.001016777   1.000000 3.904327    10
## [31] {AOC Monitor,                                                                                                        
##       Dell Desktop,                                                                                                       
##       Lenovo Desktop Computer,                                                                                            
##       ViewSonic Monitor}                                => {iMac}                    0.001118454   1.000000 3.904327    11
## [32] {Epson Printer,                                                                                                      
##       HP Monitor,                                                                                                         
##       Lenovo Desktop Computer,                                                                                            
##       ViewSonic Monitor}                                => {iMac}                    0.001016777   1.000000 3.904327    10
## [33] {Apple Magic Keyboard,                                                                                               
##       ASUS Monitor,                                                                                                       
##       HP Laptop,                                                                                                          
##       LG Monitor}                                       => {iMac}                    0.001016777   1.000000 3.904327    10
## [34] {Apple Magic Keyboard,                                                                                               
##       ASUS Monitor,                                                                                                       
##       Dell Desktop,                                                                                                       
##       Microsoft Office Home and Student 2016}           => {iMac}                    0.001016777   1.000000 3.904327    10
## [35] {Apple Magic Keyboard,                                                                                               
##       ASUS Monitor,                                                                                                       
##       HP Laptop,                                                                                                          
##       Microsoft Office Home and Student 2016}           => {iMac}                    0.001220132   1.000000 3.904327    12
## [36] {Acer Desktop,                                                                                                       
##       Apple Magic Keyboard,                                                                                               
##       ASUS Monitor,                                                                                                       
##       ViewSonic Monitor}                                => {iMac}                    0.001016777   1.000000 3.904327    10
## [37] {3-Button Mouse,                                                                                                     
##       Acer Aspire,                                                                                                        
##       Apple Magic Keyboard,                                                                                               
##       CYBERPOWER Gamer Desktop}                         => {iMac}                    0.001016777   1.000000 3.904327    10
## [38] {CYBERPOWER Gamer Desktop,                                                                                           
##       Dell Desktop,                                                                                                       
##       Samsung Monitor,                                                                                                    
##       ViewSonic Monitor}                                => {iMac}                    0.001016777   1.000000 3.904327    10
## [39] {Acer Desktop,                                                                                                       
##       HP Laptop,                                                                                                          
##       HP Monitor,                                                                                                         
##       Lenovo Desktop Computer,                                                                                            
##       ViewSonic Monitor}                                => {iMac}                    0.001118454   1.000000 3.904327    11
# Check 
inspect(head(rules_sorted, 10))
##      lhs                                                   rhs                           support confidence     lift count
## [1]  {Dell Desktop,                                                                                                       
##       iMac,                                                                                                               
##       Lenovo Desktop Computer,                                                                                            
##       Mackie CR Speakers}                               => {ViewSonic Monitor}       0.001118454   1.000000 9.064516    11
## [2]  {ASUS Monitor,                                                                                                       
##       Intel Desktop,                                                                                                      
##       ViewSonic Monitor}                                => {Lenovo Desktop Computer} 0.001118454   1.000000 6.754808    11
## [3]  {Dell KM117 Wireless Keyboard & Mouse,                                                                               
##       iPhone Charger Cable}                             => {Apple MacBook Air}       0.002033554   0.952381 6.122004    20
## [4]  {Acer Aspire,                                                                                                        
##       Koss Home Headphones,                                                                                               
##       ViewSonic Monitor}                                => {HP Laptop}               0.001220132   1.000000 5.151912    12
## [5]  {Dell Desktop,                                                                                                       
##       Koss Home Headphones,                                                                                               
##       ViewSonic Monitor}                                => {HP Laptop}               0.001118454   1.000000 5.151912    11
## [6]  {Acer Aspire,                                                                                                        
##       ASUS 2 Monitor,                                                                                                     
##       Intel Desktop}                                    => {HP Laptop}               0.001016777   1.000000 5.151912    10
## [7]  {ASUS 2 Monitor,                                                                                                     
##       Computer Game,                                                                                                      
##       Dell Desktop}                                     => {HP Laptop}               0.001016777   1.000000 5.151912    10
## [8]  {Dell Desktop,                                                                                                       
##       iMac,                                                                                                               
##       Lenovo Desktop Computer,                                                                                            
##       Logitech MK270 Wireless Keyboard and Mouse Combo} => {HP Laptop}               0.001118454   1.000000 5.151912    11
## [9]  {Acer Desktop,                                                                                                       
##       Dell Desktop,                                                                                                       
##       HDMI Cable 6ft,                                                                                                     
##       iMac}                                             => {HP Laptop}               0.001321810   1.000000 5.151912    13
## [10] {Acer Aspire,                                                                                                        
##       Computer Game,                                                                                                      
##       Dell Desktop,                                                                                                       
##       ViewSonic Monitor}                                => {HP Laptop}               0.001118454   1.000000 5.151912    11
summary(rules_sorted)
## set of 39 rules
## 
## rule length distribution (lhs + rhs):sizes
##  3  4  5  6 
##  2 14 22  1 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   3.000   4.000   5.000   4.564   5.000   6.000 
## 
## summary of quality measures:
##     support           confidence          lift           count      
##  Min.   :0.001017   Min.   :0.9524   Min.   :3.904   Min.   :10.00  
##  1st Qu.:0.001017   1st Qu.:1.0000   1st Qu.:3.904   1st Qu.:10.00  
##  Median :0.001017   Median :1.0000   Median :3.904   Median :10.00  
##  Mean   :0.001139   Mean   :0.9988   Mean   :4.550   Mean   :11.21  
##  3rd Qu.:0.001118   3rd Qu.:1.0000   3rd Qu.:5.152   3rd Qu.:11.00  
##  Max.   :0.002034   Max.   :1.0000   Max.   :9.065   Max.   :20.00  
## 
## mining info:
##              data ntransactions support confidence
##  transactions_raw          9835   0.001       0.95
str(rules)
## Formal class 'rules' [package "arules"] with 4 slots
##   ..@ lhs    :Formal class 'itemMatrix' [package "arules"] with 3 slots
##   .. .. ..@ data       :Formal class 'ngCMatrix' [package "Matrix"] with 5 slots
##   .. .. .. .. ..@ i       : int [1:158] 37 73 27 56 22 93 121 15 107 121 ...
##   .. .. .. .. ..@ p       : int [1:44] 0 2 4 7 10 13 16 19 22 25 ...
##   .. .. .. .. ..@ Dim     : int [1:2] 125 43
##   .. .. .. .. ..@ Dimnames:List of 2
##   .. .. .. .. .. ..$ : NULL
##   .. .. .. .. .. ..$ : NULL
##   .. .. .. .. ..@ factors : list()
##   .. .. ..@ itemInfo   :'data.frame':    125 obs. of  4 variables:
##   .. .. .. ..$ labels  : chr [1:125] "1TB Portable External Hard Drive" "2TB Portable External Hard Drive" "3-Button Mouse" "3TB Portable External Hard Drive" ...
##   .. .. .. ..$ il_new  : chr [1:125] "Portable HDD" "Portable HDD" "NN MiKey" "Portable HDD" ...
##   .. .. .. ..$ brand   : chr [1:125] "Unknown" "Unknown" "Unknown" "Unknown" ...
##   .. .. .. ..$ category: chr [1:125] "External Hardrives" "External Hardrives" "Mouse" "External Hardrives" ...
##   .. .. ..@ itemsetInfo:'data.frame':    0 obs. of  0 variables
##   ..@ rhs    :Formal class 'itemMatrix' [package "arules"] with 3 slots
##   .. .. ..@ data       :Formal class 'ngCMatrix' [package "Matrix"] with 5 slots
##   .. .. .. .. ..@ i       : int [1:43] 13 69 69 69 69 63 63 69 69 69 ...
##   .. .. .. .. ..@ p       : int [1:44] 0 1 2 3 4 5 6 7 8 9 ...
##   .. .. .. .. ..@ Dim     : int [1:2] 125 43
##   .. .. .. .. ..@ Dimnames:List of 2
##   .. .. .. .. .. ..$ : NULL
##   .. .. .. .. .. ..$ : NULL
##   .. .. .. .. ..@ factors : list()
##   .. .. ..@ itemInfo   :'data.frame':    125 obs. of  4 variables:
##   .. .. .. ..$ labels  : chr [1:125] "1TB Portable External Hard Drive" "2TB Portable External Hard Drive" "3-Button Mouse" "3TB Portable External Hard Drive" ...
##   .. .. .. ..$ il_new  : chr [1:125] "Portable HDD" "Portable HDD" "NN MiKey" "Portable HDD" ...
##   .. .. .. ..$ brand   : chr [1:125] "Unknown" "Unknown" "Unknown" "Unknown" ...
##   .. .. .. ..$ category: chr [1:125] "External Hardrives" "External Hardrives" "Mouse" "External Hardrives" ...
##   .. .. ..@ itemsetInfo:'data.frame':    0 obs. of  0 variables
##   ..@ quality:'data.frame':  43 obs. of  4 variables:
##   .. ..$ support   : num [1:43] 0.00203 0.00112 0.00102 0.00173 0.00102 ...
##   .. ..$ confidence: num [1:43] 0.952 1 1 1 1 ...
##   .. ..$ lift      : num [1:43] 6.12 3.9 3.9 3.9 3.9 ...
##   .. ..$ count     : num [1:43] 20 11 10 17 10 12 11 10 10 11 ...
##   ..@ info   :List of 4
##   .. ..$ data         : symbol transactions_raw
##   .. ..$ ntransactions: int 9835
##   .. ..$ support      : num 0.001
##   .. ..$ confidence   : num 0.95
## Meaning of values:
#-values too high --> no rules or non-helpful rules
#-values too low --> computational time/memory will suffer, or too many rules. 
#-to find strong rules, increase the value of confidence parameter
#-minlen = 1 --> rules with one item, means: no matter what other items are involved, 
#the item in the RHS will appear with the probability given by the rule's confidence (= support)
#To avoid these rules increase minlen (to 2)

#-lift measures importance of a rule --> high = important rule
#-Unlike confidence, {I1} -> {I2} is the same as {I2} -> {I1} in the context of the lift measurement

## Select specific rules per item
ItemRules <- subset(rules_unique, items %in% "iMac")
inspect(ItemRules)
##      lhs                                                   rhs                     support confidence     lift count
## [1]  {Brother Printer,                                                                                              
##       Halter Acrylic Monitor Stand}                     => {iMac}              0.001118454          1 3.904327    11
## [2]  {ASUS Monitor,                                                                                                 
##       Mackie CR Speakers,                                                                                           
##       ViewSonic Monitor}                                => {iMac}              0.001016777          1 3.904327    10
## [3]  {Apple Magic Keyboard,                                                                                         
##       Rii LED Gaming Keyboard & Mouse Combo,                                                                        
##       ViewSonic Monitor}                                => {iMac}              0.001728521          1 3.904327    17
## [4]  {ASUS Monitor,                                                                                                 
##       Koss Home Headphones,                                                                                         
##       Microsoft Office Home and Student 2016}           => {iMac}              0.001016777          1 3.904327    10
## [5]  {ASUS 2 Monitor,                                                                                               
##       Dell Desktop,                                                                                                 
##       Logitech Keyboard}                                => {iMac}              0.001016777          1 3.904327    10
## [6]  {Alienware Laptop,                                                                                             
##       ASUS Desktop,                                                                                                 
##       Lenovo Desktop Computer}                          => {iMac}              0.001016777          1 3.904327    10
## [7]  {Brother Printer,                                                                                              
##       Dell Desktop,                                                                                                 
##       Epson Printer}                                    => {iMac}              0.001118454          1 3.904327    11
## [8]  {Apple Magic Keyboard,                                                                                         
##       Brother Printer,                                                                                              
##       ViewSonic Monitor}                                => {iMac}              0.001016777          1 3.904327    10
## [9]  {ASUS Desktop,                                                                                                 
##       Dell Desktop,                                                                                                 
##       Microsoft Office Home and Student 2016}           => {iMac}              0.001016777          1 3.904327    10
## [10] {Intel Desktop,                                                                                                
##       iPad Pro,                                                                                                     
##       Microsoft Office Home and Student 2016}           => {iMac}              0.001118454          1 3.904327    11
## [11] {Dell Desktop,                                                                                                 
##       iMac,                                                                                                         
##       Lenovo Desktop Computer,                                                                                      
##       Mackie CR Speakers}                               => {ViewSonic Monitor} 0.001118454          1 9.064516    11
## [12] {Acer Aspire,                                                                                                  
##       Apple MacBook Pro,                                                                                            
##       HP Black & Tri-color Ink,                                                                                     
##       HP Laptop}                                        => {iMac}              0.001016777          1 3.904327    10
## [13] {Dell Desktop,                                                                                                 
##       iMac,                                                                                                         
##       Lenovo Desktop Computer,                                                                                      
##       Logitech MK270 Wireless Keyboard and Mouse Combo} => {HP Laptop}         0.001118454          1 5.151912    11
## [14] {Acer Desktop,                                                                                                 
##       Dell Desktop,                                                                                                 
##       HDMI Cable 6ft,                                                                                               
##       iMac}                                             => {HP Laptop}         0.001321810          1 5.151912    13
## [15] {Dell Desktop,                                                                                                 
##       Etekcity Power Extension Cord Cable,                                                                          
##       Lenovo Desktop Computer,                                                                                      
##       ViewSonic Monitor}                                => {iMac}              0.001220132          1 3.904327    12
## [16] {Etekcity Power Extension Cord Cable,                                                                          
##       HP Laptop,                                                                                                    
##       Lenovo Desktop Computer,                                                                                      
##       ViewSonic Monitor}                                => {iMac}              0.001626843          1 3.904327    16
## [17] {Apple Magic Keyboard,                                                                                         
##       ASUS Desktop,                                                                                                 
##       Dell Desktop,                                                                                                 
##       Lenovo Desktop Computer}                          => {iMac}              0.001016777          1 3.904327    10
## [18] {AOC Monitor,                                                                                                  
##       ASUS Monitor,                                                                                                 
##       HP Laptop,                                                                                                    
##       ViewSonic Monitor}                                => {iMac}              0.001016777          1 3.904327    10
## [19] {AOC Monitor,                                                                                                  
##       Dell Desktop,                                                                                                 
##       Lenovo Desktop Computer,                                                                                      
##       ViewSonic Monitor}                                => {iMac}              0.001118454          1 3.904327    11
## [20] {Epson Printer,                                                                                                
##       HP Monitor,                                                                                                   
##       Lenovo Desktop Computer,                                                                                      
##       ViewSonic Monitor}                                => {iMac}              0.001016777          1 3.904327    10
## [21] {Apple Magic Keyboard,                                                                                         
##       ASUS Monitor,                                                                                                 
##       HP Laptop,                                                                                                    
##       LG Monitor}                                       => {iMac}              0.001016777          1 3.904327    10
## [22] {Apple Magic Keyboard,                                                                                         
##       ASUS Monitor,                                                                                                 
##       Dell Desktop,                                                                                                 
##       Microsoft Office Home and Student 2016}           => {iMac}              0.001016777          1 3.904327    10
## [23] {Apple Magic Keyboard,                                                                                         
##       ASUS Monitor,                                                                                                 
##       HP Laptop,                                                                                                    
##       Microsoft Office Home and Student 2016}           => {iMac}              0.001220132          1 3.904327    12
## [24] {Acer Desktop,                                                                                                 
##       Apple Magic Keyboard,                                                                                         
##       ASUS Monitor,                                                                                                 
##       ViewSonic Monitor}                                => {iMac}              0.001016777          1 3.904327    10
## [25] {Apple Earpods,                                                                                                
##       Backlit LED Gaming Keyboard,                                                                                  
##       CYBERPOWER Gamer Desktop,                                                                                     
##       iMac}                                             => {HP Laptop}         0.001016777          1 5.151912    10
## [26] {3-Button Mouse,                                                                                               
##       Acer Aspire,                                                                                                  
##       Apple Magic Keyboard,                                                                                         
##       CYBERPOWER Gamer Desktop}                         => {iMac}              0.001016777          1 3.904327    10
## [27] {CYBERPOWER Gamer Desktop,                                                                                     
##       Dell Desktop,                                                                                                 
##       Samsung Monitor,                                                                                              
##       ViewSonic Monitor}                                => {iMac}              0.001016777          1 3.904327    10
## [28] {Acer Desktop,                                                                                                 
##       HP Laptop,                                                                                                    
##       HP Monitor,                                                                                                   
##       Lenovo Desktop Computer,                                                                                      
##       ViewSonic Monitor}                                => {iMac}              0.001118454          1 3.904327    11
plot(rules_sorted)
## To reduce overplotting, jitter is added! Use jitter = 0 to prevent jitter.

inspectDT(rules_sorted)                #interactive inspect
plotly_arules(rules_sorted[1:5],       #for interactive plots
              engine = "htmlwidget")   #interactive plot 
## Warning: 'plotly_arules' is deprecated.
## Use 'plot' instead.
## See help("Deprecated")
## To reduce overplotting, jitter is added! Use jitter = 0 to prevent jitter.
plot(rules_sorted[1:5], method = "two-key plot", control = list(type = "items", reorder = TRUE))
## Warning: Unknown control parameters: type, reorder
## Available control parameters (with default values):
## main  =  Scatter plot for 5 rules
## engine    =  default
## pch   =  19
## cex   =  0.5
## xlim  =  NULL
## ylim  =  NULL
## zlim  =  NULL
## alpha     =  NULL
## col   =  c("#EE0000FF", "#EE0303FF", "#EE0606FF", "#EE0909FF", "#EE0C0CFF", "#EE0F0FFF", "#EE1212FF", "#EE1515FF", "#EE1818FF", "#EE1B1BFF", "#EE1E1EFF", "#EE2222FF", "#EE2525FF", "#EE2828FF", "#EE2B2BFF", "#EE2E2EFF", "#EE3131FF", "#EE3434FF", "#EE3737FF", "#EE3A3AFF", "#EE3D3DFF", "#EE4040FF", "#EE4444FF", "#EE4747FF", "#EE4A4AFF", "#EE4D4DFF", "#EE5050FF", "#EE5353FF", "#EE5656FF", "#EE5959FF", "#EE5C5CFF", "#EE5F5FFF", "#EE6262FF", "#EE6666FF", "#EE6969FF", "#EE6C6CFF", "#EE6F6FFF", "#EE7272FF", "#EE7575FF",  "#EE7878FF", "#EE7B7BFF", "#EE7E7EFF", "#EE8181FF", "#EE8484FF", "#EE8888FF", "#EE8B8BFF", "#EE8E8EFF", "#EE9191FF", "#EE9494FF", "#EE9797FF", "#EE9999FF", "#EE9B9BFF", "#EE9D9DFF", "#EE9F9FFF", "#EEA0A0FF", "#EEA2A2FF", "#EEA4A4FF", "#EEA5A5FF", "#EEA7A7FF", "#EEA9A9FF", "#EEABABFF", "#EEACACFF", "#EEAEAEFF", "#EEB0B0FF", "#EEB1B1FF", "#EEB3B3FF", "#EEB5B5FF", "#EEB7B7FF", "#EEB8B8FF", "#EEBABAFF", "#EEBCBCFF", "#EEBDBDFF", "#EEBFBFFF", "#EEC1C1FF", "#EEC3C3FF", "#EEC4C4FF", "#EEC6C6FF", "#EEC8C8FF",  "#EEC9C9FF", "#EECBCBFF", "#EECDCDFF", "#EECFCFFF", "#EED0D0FF", "#EED2D2FF", "#EED4D4FF", "#EED5D5FF", "#EED7D7FF", "#EED9D9FF", "#EEDBDBFF", "#EEDCDCFF", "#EEDEDEFF", "#EEE0E0FF", "#EEE1E1FF", "#EEE3E3FF", "#EEE5E5FF", "#EEE7E7FF", "#EEE8E8FF", "#EEEAEAFF", "#EEECECFF", "#EEEEEEFF")
## newpage   =  TRUE
## jitter    =  NA
## verbose   =  FALSE
## To reduce overplotting, jitter is added! Use jitter = 0 to prevent jitter.

plot(rules_sorted[1:10], method = "paracoord", control = list(type = "items", reorder = TRUE))
## Warning: Unknown control parameters: type
## Available control parameters (with default values):
## main  =  Parallel coordinates plot for 10 rules
## reorder   =  FALSE
## interactive   =  FALSE
## engine    =  default
## gp_labels     =  list()
## newpage   =  TRUE
## col   =  c("#EE0000FF", "#EE0303FF", "#EE0606FF", "#EE0909FF", "#EE0C0CFF", "#EE0F0FFF", "#EE1212FF", "#EE1515FF", "#EE1818FF", "#EE1B1BFF", "#EE1E1EFF", "#EE2222FF", "#EE2525FF", "#EE2828FF", "#EE2B2BFF", "#EE2E2EFF", "#EE3131FF", "#EE3434FF", "#EE3737FF", "#EE3A3AFF", "#EE3D3DFF", "#EE4040FF", "#EE4444FF", "#EE4747FF", "#EE4A4AFF", "#EE4D4DFF", "#EE5050FF", "#EE5353FF", "#EE5656FF", "#EE5959FF", "#EE5C5CFF", "#EE5F5FFF", "#EE6262FF", "#EE6666FF", "#EE6969FF", "#EE6C6CFF", "#EE6F6FFF", "#EE7272FF", "#EE7575FF",  "#EE7878FF", "#EE7B7BFF", "#EE7E7EFF", "#EE8181FF", "#EE8484FF", "#EE8888FF", "#EE8B8BFF", "#EE8E8EFF", "#EE9191FF", "#EE9494FF", "#EE9797FF", "#EE9999FF", "#EE9B9BFF", "#EE9D9DFF", "#EE9F9FFF", "#EEA0A0FF", "#EEA2A2FF", "#EEA4A4FF", "#EEA5A5FF", "#EEA7A7FF", "#EEA9A9FF", "#EEABABFF", "#EEACACFF", "#EEAEAEFF", "#EEB0B0FF", "#EEB1B1FF", "#EEB3B3FF", "#EEB5B5FF", "#EEB7B7FF", "#EEB8B8FF", "#EEBABAFF", "#EEBCBCFF", "#EEBDBDFF", "#EEBFBFFF", "#EEC1C1FF", "#EEC3C3FF", "#EEC4C4FF", "#EEC6C6FF", "#EEC8C8FF",  "#EEC9C9FF", "#EECBCBFF", "#EECDCDFF", "#EECFCFFF", "#EED0D0FF", "#EED2D2FF", "#EED4D4FF", "#EED5D5FF", "#EED7D7FF", "#EED9D9FF", "#EEDBDBFF", "#EEDCDCFF", "#EEDEDEFF", "#EEE0E0FF", "#EEE1E1FF", "#EEE3E3FF", "#EEE5E5FF", "#EEE7E7FF", "#EEE8E8FF", "#EEEAEAFF", "#EEECECFF", "#EEEEEEFF")
## alpha     =  NULL
## quality   =  2
## verbose   =  FALSE

plot(rules_sorted[1:10], method = "graph", control = list(type = "items", reorder = TRUE))
## Warning: Unknown control parameters: type, reorder
## Available control parameters (with default values):
## main  =  Graph for 10 rules
## nodeColors    =  c("#66CC6680", "#9999CC80")
## nodeCol   =  c("#EE0000FF", "#EE0303FF", "#EE0606FF", "#EE0909FF", "#EE0C0CFF", "#EE0F0FFF", "#EE1212FF", "#EE1515FF", "#EE1818FF", "#EE1B1BFF", "#EE1E1EFF", "#EE2222FF", "#EE2525FF", "#EE2828FF", "#EE2B2BFF", "#EE2E2EFF", "#EE3131FF", "#EE3434FF", "#EE3737FF", "#EE3A3AFF", "#EE3D3DFF", "#EE4040FF", "#EE4444FF", "#EE4747FF", "#EE4A4AFF", "#EE4D4DFF", "#EE5050FF", "#EE5353FF", "#EE5656FF", "#EE5959FF", "#EE5C5CFF", "#EE5F5FFF", "#EE6262FF", "#EE6666FF", "#EE6969FF", "#EE6C6CFF", "#EE6F6FFF", "#EE7272FF", "#EE7575FF",  "#EE7878FF", "#EE7B7BFF", "#EE7E7EFF", "#EE8181FF", "#EE8484FF", "#EE8888FF", "#EE8B8BFF", "#EE8E8EFF", "#EE9191FF", "#EE9494FF", "#EE9797FF", "#EE9999FF", "#EE9B9BFF", "#EE9D9DFF", "#EE9F9FFF", "#EEA0A0FF", "#EEA2A2FF", "#EEA4A4FF", "#EEA5A5FF", "#EEA7A7FF", "#EEA9A9FF", "#EEABABFF", "#EEACACFF", "#EEAEAEFF", "#EEB0B0FF", "#EEB1B1FF", "#EEB3B3FF", "#EEB5B5FF", "#EEB7B7FF", "#EEB8B8FF", "#EEBABAFF", "#EEBCBCFF", "#EEBDBDFF", "#EEBFBFFF", "#EEC1C1FF", "#EEC3C3FF", "#EEC4C4FF", "#EEC6C6FF", "#EEC8C8FF",  "#EEC9C9FF", "#EECBCBFF", "#EECDCDFF", "#EECFCFFF", "#EED0D0FF", "#EED2D2FF", "#EED4D4FF", "#EED5D5FF", "#EED7D7FF", "#EED9D9FF", "#EEDBDBFF", "#EEDCDCFF", "#EEDEDEFF", "#EEE0E0FF", "#EEE1E1FF", "#EEE3E3FF", "#EEE5E5FF", "#EEE7E7FF", "#EEE8E8FF", "#EEEAEAFF", "#EEECECFF", "#EEEEEEFF")
## edgeCol   =  c("#474747FF", "#494949FF", "#4B4B4BFF", "#4D4D4DFF", "#4F4F4FFF", "#515151FF", "#535353FF", "#555555FF", "#575757FF", "#595959FF", "#5B5B5BFF", "#5E5E5EFF", "#606060FF", "#626262FF", "#646464FF", "#666666FF", "#686868FF", "#6A6A6AFF", "#6C6C6CFF", "#6E6E6EFF", "#707070FF", "#727272FF", "#747474FF", "#767676FF", "#787878FF", "#7A7A7AFF", "#7C7C7CFF", "#7E7E7EFF", "#808080FF", "#828282FF", "#848484FF", "#868686FF", "#888888FF", "#8A8A8AFF", "#8C8C8CFF", "#8D8D8DFF", "#8F8F8FFF", "#919191FF", "#939393FF",  "#959595FF", "#979797FF", "#999999FF", "#9A9A9AFF", "#9C9C9CFF", "#9E9E9EFF", "#A0A0A0FF", "#A2A2A2FF", "#A3A3A3FF", "#A5A5A5FF", "#A7A7A7FF", "#A9A9A9FF", "#AAAAAAFF", "#ACACACFF", "#AEAEAEFF", "#AFAFAFFF", "#B1B1B1FF", "#B3B3B3FF", "#B4B4B4FF", "#B6B6B6FF", "#B7B7B7FF", "#B9B9B9FF", "#BBBBBBFF", "#BCBCBCFF", "#BEBEBEFF", "#BFBFBFFF", "#C1C1C1FF", "#C2C2C2FF", "#C3C3C4FF", "#C5C5C5FF", "#C6C6C6FF", "#C8C8C8FF", "#C9C9C9FF", "#CACACAFF", "#CCCCCCFF", "#CDCDCDFF", "#CECECEFF", "#CFCFCFFF", "#D1D1D1FF",  "#D2D2D2FF", "#D3D3D3FF", "#D4D4D4FF", "#D5D5D5FF", "#D6D6D6FF", "#D7D7D7FF", "#D8D8D8FF", "#D9D9D9FF", "#DADADAFF", "#DBDBDBFF", "#DCDCDCFF", "#DDDDDDFF", "#DEDEDEFF", "#DEDEDEFF", "#DFDFDFFF", "#E0E0E0FF", "#E0E0E0FF", "#E1E1E1FF", "#E1E1E1FF", "#E2E2E2FF", "#E2E2E2FF", "#E2E2E2FF")
## alpha     =  0.5
## cex   =  1
## itemLabels    =  TRUE
## labelCol  =  #000000B3
## measureLabels     =  FALSE
## precision     =  3
## layout    =  NULL
## layoutParams  =  list()
## arrowSize     =  0.5
## engine    =  igraph
## plot  =  TRUE
## plot_options  =  list()
## max   =  100
## verbose   =  FALSE

5. Selection of rules